package com.gqr.uncaughtException;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Copyright (C), 2020-2024,gqr
 * FileName:MyUncaughtExceptionHandler
 * author:guqingrong
 * Date:2024-04-25 22:15
 * Description: 自定义uncaughtException
 * History:
 * <author>    <time>    <version>    <desc>
 * 作者姓名     修改时间     版本号        描述
 */
public class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
    private String name;

    public MyUncaughtExceptionHandler(String name) {
        this.name = name;
    }

    @Override
    public void uncaughtException(Thread t, Throwable e) {
        Logger logger = Logger.getAnonymousLogger();
        logger.log(Level.WARNING, "线程异常,终止啦" + t.getName(), e);
        System.out.println(name + "捕获了异常" + t.getName() + "异常" + e);
    }
}
